<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:output
		encoding="utf-8"
		indent="yes"
		doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
		omit-xml-declaration="yes"
		method="xml" />
		
	<xsl:param name="userId" select="@user-id" />
	<xsl:param name="typeName" select="data/response/@type-name" />
	<xsl:param name="objectId" select="data/response/@object-id" />
	<xsl:param name="baseURI" select="/data/@base-uri" />
	
	<xsl:template match="data/response">
		<xsl:param name="cntMembers" select="count(object[@type='blog_member'])" />
		
		<div class="line">
			<div class="block">
				<h1>Администраторы</h1>
				
				<xsl:if test="count (object[@type='blog_admin']) = 0">
					<div>Удивительно, но у этого блога нет администраторов</div>
				</xsl:if>
				
				<div class="users">
					<xsl:apply-templates select="object[@type='blog_admin']" mode="boss" />
				</div>
			</div>
			
			<div class="block">
				<h1>Модераторы</h1>
				
				<xsl:if test="count (object[@type='blog_moderator']) = 0">
					<div>Никто не модерирует этот блог</div>
				</xsl:if>
				
				<div class="users">
					<xsl:apply-templates select="object[@type='blog_moderator']" mode="boss" />
				</div>
			</div>
		</div>
		
		<div class="line">
			<h1>
				<xsl:text>Участники (</xsl:text>
				<xsl:value-of select="$cntMembers" />
				<xsl:text>)</xsl:text>
			</h1>
			<xsl:choose>
				<xsl:when test="$cntMembers = 0">
					<div>Удивительно, но нет ни одного участника</div>
				</xsl:when>
				<xsl:otherwise>
					<ul class="members">
						<xsl:apply-templates select="object[@type='blog_member']" mode="member" />
					</ul>
				</xsl:otherwise>
			</xsl:choose>
		</div>
	</xsl:template>
	
	<xsl:template match="response/object[@type = 'blog_admin' or @type = 'blog_moderator']" mode="boss">
		<xsl:param name="login" select="property[@name='user_login']/value" />
		<xsl:param name="avatar" select="property[@name='user_avatar']/value" />
		
		<div class="item">
			<div class="avatar">
				<a href="{$baseURI}/user/{$login}">
					<xsl:if test="$avatar != ''">
						<img src="{$baseURI}/thumb_50_50{$avatar}" alt="{$login}" />
					</xsl:if>
					<xsl:if test="$avatar = ''">
						<img src="{$baseURI}/images/default-user-avatar.png" alt="{$login}" />
					</xsl:if>
					
					<i class="corner-mask-f8-5 tl"></i>
					<i class="corner-mask-f8-5 tr"></i>
					<i class="corner-mask-f8-5 br"></i>
					<i class="corner-mask-f8-5 bl"></i>
				</a>
			</div>
			<div class="name">
				<a href="{$baseURI}/user/{$login}">
					<xsl:value-of select="$login" />
				</a>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template match="response/object[@type = 'blog_member']" mode="member">
		<xsl:param name="login" select="property[@name='user_login']/value" />
		
		<li>
			<a href="{$baseURI}/user/{$login}">
				<xsl:value-of select="$login" />
			</a>
		</li>
	</xsl:template>
	
</xsl:stylesheet>